package simple.framework.util;

import java.util.Date;
import java.util.Calendar;
import java.util.TimeZone;
import java.util.Random;
import java.util.regex.*;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;

public class cls {

    public static String cfnames(String argFpre, String argString) {
        String tmpstr = "";
        String tFpre = argFpre;
        String tString = argString;
        tmpstr = concat(tFpre, tString);
        return tmpstr;
    }

    public static String concat(String argString1, String argString2) {
        String tmpstr = "";
        String tString1 = argString1;
        String tString2 = argString2;
        tString1 = getString(tString1);
        tString2 = getString(tString2);
        tmpstr = tString1 + tString2;
        return tmpstr;
    }

    public static String cper(Integer argNum1, Integer argNum2) {
        String tmpstr = "0";
        Integer tNum1 = argNum1;
        Integer tNum2 = argNum2;
        String tNum1String = toString(tNum1);
        String tNum2String = toString(tNum2);
        if (!(tNum1.equals(0) || tNum2.equals(0))) {
            tmpstr = cls.toString((cls.getDouble(tNum1String) / cls.getDouble(tNum2String)) * 100);
        }
        tmpstr = getLRStr(tmpstr, ".", "left");
        return tmpstr;
    }

    public static String ctemplate(String argTemplate, String argString) {
        String tmpstr = "";
        String tTemplate = argTemplate;
        String tString = argString;
        if (!cls.isEmpty(tTemplate) && tTemplate.indexOf(tString) >= 0) {
            String tTemplateB = "<!--fixed-->" + tTemplate + "<!--fixed-->";
            String[] tAry = tTemplateB.split(Pattern.quote(tString));
            if (tAry.length == 3) {
                tmpstr = tAry[1];
            }
        }
        return tmpstr;
    }

    public static String ctemplates(String argTemplate, String argString, String argContent) {
        String tmpstr = "";
        String tTemplate = argTemplate;
        String tString = argString;
        String tContent = argContent;
        if (!cls.isEmpty(tTemplate) && tTemplate.indexOf(tString) >= 0) {
            String tTemplateB = "<!--fixed-->" + tTemplate + "<!--fixed-->";
            String[] tAry = tTemplateB.split(Pattern.quote(tString));
            if (tAry.length == 3) {
                tmpstr = tTemplate.replace(tString + tAry[1] + tString, tContent);
            }
        }
        return tmpstr;
    }

    public static Boolean cidary(String argString) {
        Boolean tbool = false;
        String tString = getString(argString);
        if (!isEmpty(tString)) {
            tbool = true;
            String[] tAry = tString.split(Pattern.quote(","));
            for (int ti = 0; ti < tAry.length; ti++) {
                if (getNum(tAry[ti], -1) == -1) {
                    tbool = false;
                    break;
                }
            }
        }
        return tbool;
    }

    public static Boolean cinstr(String argString, String argStr, String argSpstr) {
        Boolean tbool = false;
        String tString = argString;
        String tStr = argStr;
        String tSpstr = argSpstr;
        if (tString.equals(tStr)) {
            tbool = true;
        } else {
            if (tString.indexOf(tSpstr + tStr + tSpstr) >= 0) {
                tbool = true;
            } else {
                if (getLRStr(tString, tSpstr, "left").equals(tStr)) {
                    tbool = true;
                } else {
                    if (getLRStr(tString, tSpstr, "right").equals(tStr)) {
                        tbool = true;
                    }
                }
            }
        }
        return tbool;
    }

    public static Boolean cinstrs(String argString, String argStr, String argSpstr) {
        Boolean tbool = false;
        String tString = argString;
        String tStr = argStr;
        String tSpstr = argSpstr;
        if (tString.equals(tStr)) {
            tbool = true;
        } else {
            tbool = true;
            String[] tAry = tStr.split(Pattern.quote(tSpstr));
            for (int ti = 0; ti < tAry.length; ti++) {
                if (!cinstr(tString, tAry[ti], tSpstr)) {
                    tbool = false;
                }
            }
        }
        return tbool;
    }

    public static String dateAdd(String argInterval, Integer argNumber, String argDate) {
        String tDate = argDate;
        Integer tNumber = argNumber;
        String tInterval = argInterval;
        Integer tSeconds = 0;
        tDate = getDate(tDate);
        if (tInterval.equals("s")) {
            tSeconds = tNumber;
        } else if (tInterval.equals("n")) {
            tSeconds = tNumber * 60;
        } else if (tInterval.equals("h")) {
            tSeconds = tNumber * 60 * 60;
        } else if (tInterval.equals("d")) {
            tSeconds = tNumber * 60 * 60 * 24;
        } else {
            tSeconds = tNumber;
        }
        try {
            Date tDateTime;
            Calendar tCalendar = Calendar.getInstance();
            SimpleDateFormat tSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            tDateTime = tSimpleDateFormat.parse(tDate);
            tCalendar.setTime(tDateTime);
            tCalendar.add(Calendar.SECOND, tSeconds);
            String tCurrentDateTime = toString(tCalendar.get(Calendar.YEAR)) + "-" + toString(tCalendar.get(Calendar.MONTH) + 1) + "-" + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE)) + ":" + toString(tCalendar.get(Calendar.SECOND));
            tDate = formatDate(tCurrentDateTime);
        } catch (Exception e) {
        }
        return tDate;
    }

    public static String formatByte(String argByte) {
        String tByte = argByte;
        String tByteString = formatByte(getNum64(tByte, 0L));
        return tByteString;
    }

    public static String formatByte(Long argByte) {
        Long tByte = argByte;
        String tmpstr = "";
        if (tByte > 1073741824) {
            tmpstr = toString(Math.round(tByte / 1073741824.0 * 1000.0) / 1000.0) + " GB";
        } else {
            if (tByte > 1048576) {
                tmpstr = toString(Math.round(tByte / 1048576.0 * 1000.0) / 1000.0) + " MB";
            } else {
                if (tByte > 1024) {
                    tmpstr = toString(Math.round(tByte / 1024.0 * 1000.0) / 1000.0) + " KB";
                } else {
                    tmpstr = toString(tByte) + " B";
                }
            }
        }
        return tmpstr;
    }

    public static String formatDate(String argDatestr) {
        String tmpstr = "";
        String tDatestr = argDatestr;
        tmpstr = formatDate(tDatestr, 100);
        return tmpstr;
    }

    public static String formatDate(Date argDate) {
        String tmpstr = "";
        Date tDate = argDate;
        tmpstr = formatDate(tDate, 100);
        return tmpstr;
    }

    public static String formatDate(String argDatestr, Integer argType) {
        Integer tType = argType;
        String tDatestr = argDatestr;
        String tmpstr = tDatestr;
        SimpleDateFormat tSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date tDateTime = tSimpleDateFormat.parse(tDatestr);
            tmpstr = formatDate(tDateTime, tType);
        } catch (Exception e) {
        }
        return tmpstr;
    }

    public static String formatDate(Date argDate, Integer argType) {
        String tmpstr = "";
        Integer tType = argType;
        Date tDateTime = argDate;
        try {
            Calendar tCalendar = Calendar.getInstance();
            tCalendar.setTime(tDateTime);
            switch (tType) {
                case -3:
                    tmpstr = toString(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case -2:
                    tmpstr = toString(tCalendar.get(Calendar.MONTH) + 1);
                    break;
                case -1:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR));
                    break;
                case 0:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + toString(tCalendar.get(Calendar.MONTH) + 1) + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + toString(tCalendar.get(Calendar.MINUTE)) + toString(tCalendar.get(Calendar.SECOND));
                    break;
                case 1:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "-" + toString(tCalendar.get(Calendar.MONTH) + 1) + "-" + toString(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 2:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "/" + toString(tCalendar.get(Calendar.MONTH) + 1) + "/" + toString(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 3:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "." + toString(tCalendar.get(Calendar.MONTH) + 1) + "." + toString(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 4:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "-" + formatTime(tCalendar.get(Calendar.MONTH) + 1) + "-" + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 5:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "/" + formatTime(tCalendar.get(Calendar.MONTH) + 1) + "/" + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 6:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "." + formatTime(tCalendar.get(Calendar.MONTH) + 1) + "." + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 7:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + formatTime(tCalendar.get(Calendar.MONTH) + 1) + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH));
                    break;
                case 10:
                    tmpstr = toString(tCalendar.get(Calendar.MONTH) + 1) + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + toString(tCalendar.get(Calendar.MINUTE));
                    break;
                case 11:
                    tmpstr = toString(tCalendar.get(Calendar.MONTH) + 1) + "-" + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE));
                    break;
                case 12:
                    tmpstr = toString(tCalendar.get(Calendar.MONTH) + 1) + "/" + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE));
                    break;
                case 13:
                    tmpstr = toString(tCalendar.get(Calendar.MONTH) + 1) + "." + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE));
                    break;
                case 14:
                    tmpstr = formatTime(tCalendar.get(Calendar.MONTH) + 1) + "-" + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + formatTime(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + formatTime(tCalendar.get(Calendar.MINUTE));
                    break;
                case 15:
                    tmpstr = formatTime(tCalendar.get(Calendar.MONTH) + 1) + "/" + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + formatTime(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + formatTime(tCalendar.get(Calendar.MINUTE));
                    break;
                case 16:
                    tmpstr = formatTime(tCalendar.get(Calendar.MONTH) + 1) + "." + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + formatTime(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + formatTime(tCalendar.get(Calendar.MINUTE));
                    break;
                case 20:
                    tmpstr = toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + toString(tCalendar.get(Calendar.MINUTE)) + toString(tCalendar.get(Calendar.SECOND));
                    break;
                case 21:
                    tmpstr = toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE)) + ":" + toString(tCalendar.get(Calendar.SECOND));
                    break;
                case 30:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + formatTime(tCalendar.get(Calendar.MONTH) + 1) + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH)) + formatTime(tCalendar.get(Calendar.HOUR_OF_DAY)) + formatTime(tCalendar.get(Calendar.MINUTE)) + formatTime(tCalendar.get(Calendar.SECOND));
                    break;
                case 100:
                    tmpstr = toString(tCalendar.get(Calendar.YEAR)) + "-" + formatTime(tCalendar.get(Calendar.MONTH) + 1) + "-" + formatTime(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + formatTime(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + formatTime(tCalendar.get(Calendar.MINUTE)) + ":" + formatTime(tCalendar.get(Calendar.SECOND));
                    break;
            }
        } catch (Exception e) {
        }
        return tmpstr;
    }

    public static String formatDouble(Double argDouble, String argIType) {
        String tmpstr = "";
        Double tDouble = argDouble;
        String tIType = argIType;
        DecimalFormat tDecimalFormat = new DecimalFormat(tIType);
        tmpstr = tDecimalFormat.format(tDouble);
        return tmpstr;
    }

    public static String formatTime(Integer argNum) {
        String tmpstr = "";
        Integer tNum = argNum;
        if (tNum < 10) {
            tmpstr = "0";
        }
        tmpstr += toString(tNum);
        return tmpstr;
    }

    public static String formatText(String argString, String argTpl, String argSpString) {
        String tmpstr = "";
        String tString = argString;
        String tTpl = argTpl;
        String tSpString = argSpString;
        if (!cls.isEmpty(tString)) {
            String[] tStringAry = tString.split(Pattern.quote(tSpString));
            for (int ti = 0; ti < tStringAry.length; ti++) {
                tmpstr += tTpl;
                String tnText = getString(tStringAry[ti]);
                tmpstr = tmpstr.replace("[text]", tnText);
                tmpstr = tmpstr.replace("[i]", cls.toString(ti));
                tmpstr = tmpstr.replace("[text-htmlencode]", encode.htmlencode(tnText));
                tmpstr = tmpstr.replace("[text-base64encode]", encode.base64encode(tnText.getBytes()));
            }
        }
        return tmpstr;
    }

    public static String formatTextLine(String argString, String argTpl) {
        String tmpstr = "";
        String tString = argString;
        String tTpl = argTpl;
        tString = tString.replace(String.valueOf((char) 13) + String.valueOf((char) 10), String.valueOf((char) 10));
        tString = tString.replace(String.valueOf((char) 10), String.valueOf((char) 13) + String.valueOf((char) 10));
        String tSpString = String.valueOf((char) 13) + String.valueOf((char) 10);
        if (!cls.isEmpty(tString)) {
            String[] tStringAry = tString.split(Pattern.quote(tSpString));
            for (int ti = 0; ti < tStringAry.length; ti++) {
                tmpstr += tTpl;
                String tnText = getString(tStringAry[ti]);
                tmpstr = tmpstr.replace("[text]", tnText);
                tmpstr = tmpstr.replace("[i]", cls.toString(ti));
                tmpstr = tmpstr.replace("[text-htmlencode]", encode.htmlencode(tnText));
                tmpstr = tmpstr.replace("[text-base64encode]", encode.base64encode(tnText.getBytes()));
            }
        }
        return tmpstr;
    }

    public static String formatUnixStampDate(Long argNum) {
        String tDate = "";
        Long tNum = argNum;
        SimpleDateFormat tSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            TimeZone tTimeZone = TimeZone.getTimeZone("UTC");
            Calendar tCalendar = Calendar.getInstance(tTimeZone);
            tCalendar.setTimeInMillis(tNum * 1000);
            String tnDateTime = toString(tCalendar.get(Calendar.YEAR)) + "-" + toString(tCalendar.get(Calendar.MONTH) + 1) + "-" + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE)) + ":" + toString(tCalendar.get(Calendar.SECOND));
            tDate = formatDate(tnDateTime);
        } catch (Exception e) {
        }
        return tDate;
    }

    public static Object getAryValue(Object[][] argAry, String argString) {
        Object tobject = null;
        Object[][] tAry = argAry;
        String tString = argString;
        for (int ti = 0; ti < tAry.length; ti++) {
            if (tString.equals(toString(tAry[ti][0]))) {
                tobject = tAry[ti][1];
                break;
            }
        }
        return tobject;
    }

    public static String getDate() {
        String tDate = "";
        TimeZone tTimeZone = TimeZone.getTimeZone("GMT+8");
        Calendar tCalendar = Calendar.getInstance(tTimeZone);
        String tnDateTime = toString(tCalendar.get(Calendar.YEAR)) + "-" + toString(tCalendar.get(Calendar.MONTH) + 1) + "-" + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE)) + ":" + toString(tCalendar.get(Calendar.SECOND));
        tDate = formatDate(tnDateTime);
        return tDate;
    }

    public static String getDate(String argDate) {
        String tDate = argDate;
        SimpleDateFormat tSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date tDateTime = tSimpleDateFormat.parse(tDate);
            Calendar tCalendar = Calendar.getInstance();
            tCalendar.setTime(tDateTime);
            String tnDateTime = toString(tCalendar.get(Calendar.YEAR)) + "-" + toString(tCalendar.get(Calendar.MONTH) + 1) + "-" + toString(tCalendar.get(Calendar.DAY_OF_MONTH)) + " " + toString(tCalendar.get(Calendar.HOUR_OF_DAY)) + ":" + toString(tCalendar.get(Calendar.MINUTE)) + ":" + toString(tCalendar.get(Calendar.SECOND));
            tDate = formatDate(tnDateTime);
        } catch (Exception e) {
            tDate = getDate();
        }
        return tDate;
    }

    public static Double getDouble(String argString) {
        Double tDouble = 0.0;
        String tString = argString;
        tDouble = getDouble(tString, 0.0);
        return tDouble;
    }

    public static Double getDouble(String argString, Double argDefault) {
        String tString = argString;
        Double tDefault = argDefault;
        Double tDouble = tDefault;
        try {
            tDouble = Double.parseDouble(tString);
        } catch (Exception e) {
        }
        return tDouble;
    }

    public static String getRandomString(int argLength) {
        String tmpstr = "";
        int tLength = argLength;
        String tString = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
        String[] tAry = tString.split(Pattern.quote(","));
        Random tRandom = new Random();
        for (int ti = 0; ti < tLength; ti++) {
            int tn = tRandom.nextInt(tAry.length);
            tmpstr += tAry[tn];
        }
        return tmpstr;
    }

    public static Long getUnixStamp() {
        String tNow = getDate();
        Long tUnixStamp = getUnixStamp(tNow);
        return tUnixStamp;
    }

    public static Long getUnixStamp(String argDate) {
        Long tUnixStamp = 0L;
        String tDate = argDate;
        String tDateTime = getDate(tDate);
        SimpleDateFormat tSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date tDate1 = tSimpleDateFormat.parse(tDateTime);
            Date tDate2 = tSimpleDateFormat.parse("1970-1-1 0:00:00");
            tUnixStamp = (tDate1.getTime() - tDate2.getTime()) / 1000;
        } catch (Exception e) {
        }
        return tUnixStamp;
    }

    public static String getHstr(String argString1, String argString2) {
        String tmpstr = "";
        String tString1 = getString(argString1);
        String tString2 = getString(argString2);
        tmpstr = tString1;
        if (isEmpty(tmpstr)) {
            tmpstr = tString2;
        }
        return tmpstr;
    }

    public static String getLeft(String argString, Integer argLength) {
        String tmpstr = "";
        String tString = argString;
        Integer tLength = argLength;
        tmpstr = getLeft(tString, tLength, "");
        return tmpstr;
    }

    public static String getLeft(String argString, Integer argLength, String argEllipsis) {
        String tmpstr = "";
        Integer tLength = argLength;
        String tString = getString(argString);
        String tEllipsis = getString(argEllipsis);
        if (!isEmpty(tString)) {
            if (tLength > tString.length()) {
                tLength = tString.length();
            }
            tmpstr = tString.substring(0, tLength);
        }
        if (!tmpstr.equals(tString)) {
            tmpstr += tEllipsis;
        }
        return tmpstr;
    }

    public static String getLeftB(String argString, Integer argLength) {
        String tmpstr = "";
        String tString = argString;
        Integer tLength = argLength;
        tmpstr = getLeftB(tString, tLength, "");
        return tmpstr;
    }

    public static String getLeftB(String argString, Integer argLength, String argEllipsis) {
        String tmpstr = "";
        Integer tLength = argLength;
        String tString = getString(argString);
        String tEllipsis = getString(argEllipsis);
        if (!cls.isEmpty(tString)) {
            Integer tnLength = 0;
            for (int ti = 0; ti < tString.length(); ti++) {
                String tnString = tString.substring(ti, ti + 1);
                if (validator.isChinese(tnString)) {
                    tnLength += 2;
                } else {
                    tnLength += 1;
                }
                if (tnLength <= tLength) {
                    tmpstr += tnString;
                } else {
                    break;
                }
            }
        }
        if (!tmpstr.equals(tString)) {
            tmpstr += tEllipsis;
        }
        return tmpstr;
    }

    public static Integer getNum(String argString) {
        String tString = argString;
        Integer tNum = getNum(tString, 0);
        return tNum;
    }

    public static Integer getNum(String argString, Integer argDefault) {
        String tString = argString;
        Integer tDefault = argDefault;
        Integer tNum = tDefault;
        try {
            tNum = Integer.parseInt(tString);
        } catch (Exception e) {
        }
        return tNum;
    }

    public static Long getNum64(String argString) {
        String tString = argString;
        Long tNum64 = getNum64(tString, 0L);
        return tNum64;
    }

    public static Long getNum64(String argString, Long argDefault) {
        String tString = argString;
        Long tDefault = argDefault;
        Long tNum64 = tDefault;
        try {
            tNum64 = Long.parseLong(tString);
        } catch (Exception e) {
        }
        return tNum64;
    }

    public static String getRight(String argString, Integer argLength) {
        String tmpstr = "";
        Integer tLength = argLength;
        String tString = getString(argString);
        if (!isEmpty(tString)) {
            Integer tLength2 = tString.length();
            Integer tLength1 = tLength2 - tLength;
            if (tLength1 < 0) {
                tLength1 = 0;
            }
            tmpstr = tString.substring(tLength1, tLength2);
        }
        return tmpstr;
    }

    public static String getRepeatedString(String argString, Integer argNum) {
        String tString = argString;
        Integer tNum = argNum;
        String tmpstr = "";
        for (int ti = 1; ti < tNum; ti++) {
            tmpstr += tString;
        }
        return tmpstr;
    }

    public static String getString(String argString) {
        String tString = argString;
        if (tString == null) {
            tString = "";
        }
        return tString;
    }

    public static String getSafeString(String argString) {
        String tString = argString;
        tString = getString(tString);
        tString = tString.replace("'", "");
        tString = tString.replace(";", "");
        tString = tString.replace("--", "");
        return tString;
    }

    public static String getLRStr(String argString, String argSpstr, String argType) {
        String tmpstr = "";
        String tString = argString;
        String tSpstr = argSpstr;
        String tType = argType;
        if (isEmpty(tSpstr) || tString.indexOf(tSpstr) == -1) {
            tmpstr = tString;
        } else {
            if (tType.equals("left")) {
                tmpstr = tString.substring(0, tString.indexOf(tSpstr));
            } else if (tType.equals("leftr")) {
                tmpstr = tString.substring(0, tString.lastIndexOf(tSpstr));
            } else if (tType.equals("right")) {
                tmpstr = tString.substring(tString.lastIndexOf(tSpstr) + tSpstr.length(), tString.length());
            } else if (tType.equals("rightr")) {
                tmpstr = tString.substring(tString.indexOf(tSpstr) + tSpstr.length(), tString.length());
            } else {
                tmpstr = tString;
            }
        }
        return tmpstr;
    }

    public static String getParameter(String argString, String argKey) {
        String tmpstr = "";
        String tString = argString;
        String tKey = argKey;
        tmpstr = getParameter(tString, tKey, ";");
        return tmpstr;
    }

    public static String getParameter(String argString, String argKey, String argSpstr) {
        String tmpstr = "";
        String tString = argString;
        String tKey = argKey;
        String tSpstr = argSpstr;
        Pattern tPattern = Pattern.compile("((?:^|" + tSpstr + ")" + tKey + "=(.[^" + tSpstr + "]*))");
        Matcher tMatcher = tPattern.matcher(tString);
        if (tMatcher.find()) {
            tmpstr = tMatcher.group(2);
        }
        return tmpstr;
    }

    public static Boolean isEmpty(Object argObject) {
        Boolean tbool = false;
        Object tObject = argObject;
        String tString = toString(tObject);
        if (tString.equals("")) {
            tbool = true;
        }
        return tbool;
    }

    public static Object[] mergeAry(Object[] argAry1, Object[][] argAry2) {
        Object[] tAry = null;
        Object[] tAry1 = argAry1;
        Object[][] tAry2 = argAry2;
        if (tAry1 == null) {
            tAry = new Object[1];
            tAry[0] = tAry2;
        } else {
            int tAry1Length = tAry1.length;
            tAry = new Object[tAry1Length + 1];
            for (int ti = 0; ti < tAry1Length; ti++) {
                tAry[ti] = tAry1[ti];
            }
            tAry[(tAry.length - 1)] = tAry2;
        }
        return tAry;
    }

    public static String[][] mergeAry(String[][] argAry1, String[][] argAry2) {
        String[][] tAry = null;
        String[][] tAry1 = argAry1;
        String[][] tAry2 = argAry2;
        if (tAry1 == null) {
            tAry = tAry2;
        }
        if (tAry2 == null) {
            tAry = tAry1;
        }
        if (tAry == null) {
            Integer tAry1Length0 = tAry1.length;
            Integer tAry1Length1 = tAry1[0].length;
            Integer tAry2Length0 = tAry2.length;
            Integer tAry2Length1 = tAry2[0].length;
            if (tAry1Length1.equals(tAry2Length1)) {
                tAry = new String[(tAry1Length0 + tAry2Length0)][tAry1Length1];
                for (int ti = 0; ti < tAry1Length0; ti++) {
                    for (int tj = 0; tj < tAry1Length1; tj++) {
                        tAry[ti][tj] = tAry1[ti][tj];
                    }
                }
                for (int ti = 0; ti < tAry2Length0; ti++) {
                    for (int tj = 0; tj < tAry2Length1; tj++) {
                        tAry[(ti + tAry1Length0)][tj] = tAry2[ti][tj];
                    }
                }
            }
        }
        return tAry;
    }

    public static String replace(String argString1, String argString2, String argString3) {
        String tString1 = getString(argString1);
        String tString2 = getString(argString2);
        String tString3 = getString(argString3);
        if (!isEmpty(tString1)) {
            tString1 = tString1.replace(tString2, tString3);
        }
        return tString1;
    }

    public static String reparameter(String argPare, String argKey, String argValue) {
        String tmpstr = "";
        String tPare = argPare;
        String tKey = argKey;
        String tValue = argValue;
        if (isEmpty(tPare)) {
            tmpstr = tKey + "=" + tValue;
        } else {
            String tMyPare = "&" + tPare;
            if (tMyPare.indexOf("&" + tKey + "=") == -1) {
                tmpstr = tPare + "&" + tKey + "=" + tValue;
            } else {
                String tmpstring1 = getLRStr(tMyPare, "&" + tKey + "=", "rightr");
                tmpstring1 = getLRStr(tmpstring1, "&", "left");
                tmpstr = tMyPare.replace("&" + tKey + "=" + tmpstring1, "&" + tKey + "=" + tValue);
                tmpstr = cls.getLRStr(tmpstr, "&", "rightr");
            }
        }
        return tmpstr;
    }

    public static String toString(Object argObject) {
        String tmpstr = "";
        Object tObject = argObject;
        if (tObject != null) {
            tmpstr = tObject.toString();
        }
        return tmpstr;
    }
}